package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    // 新增
    @Insert("insert into sky_take_out.setmeal_dish values (null,#{setmealId},#{dishId},#{name},#{price},#{copies})")
    void save(SetmealDish setmealDish);

    // 根据套餐id查询菜品集合
    @Select("select * from sky_take_out.setmeal_dish where setmeal_id=#{sid}")
    List<SetmealDish> findBySetmealId(Long sid);

    // 根据套餐id删除菜品集合
    @Delete("delete from sky_take_out.setmeal_dish where setmeal_id=#{sid}")
    void deleteBySetmealId(Long sid);

    @Select("select count(*) from sky_take_out.setmeal_dish where dish_id =#{id}")
    Integer count(Long id);

    @Select("select count(*) from sky_take_out.setmeal_dish where dish_id =#{id}")
    Integer number(Long id);

    //根据套餐id查询菜品列表
    @Select("select d.name,d.image,d.description,sd.copies from setmeal_dish sd join dish d on sd.dish_id = d.id where sd.setmeal_id=#{setmealId}")
    List<DishItemVO> findDishItemsBySetmealId(Long setmealId);
}